package com.yunhe.authority.controller.authority;

import com.github.stuxuhai.jpinyin.PinyinException;
import com.yunhe.authority.domain.authority.Firm;
import com.yunhe.authority.domain.authority.Project;
import com.yunhe.authority.service.authority.FirmService;
import com.yunhe.common.annotation.OperationRecord;
import com.yunhe.common.constant.SystemConsts;
import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.model.ResultObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * 单位Controller
 * @author liuronglei
 */
@Api(value = "firm",description = "单位维护", tags = {"Authority_Firm"})
@RestController
@RequestMapping("/firms")
public class FirmController {
    private static final Logger logger = LoggerFactory.getLogger(FirmController.class);
    @Autowired
    private FirmService firmService;
    /**
     * 新增单位
     * @param firm 单位对象
     */
    @ApiOperation("新增单位")
    @RequestMapping(method = RequestMethod.POST)
    @OperationRecord(menu = "单位管理", actionType = SystemConsts.ACTION.ADD)
    public ResponseEntity<ResultObject> post(@RequestBody Firm firm)
            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException, PinyinException {
        Firm newFirm = firmService.createFirm(firm);
        return new ResponseEntity<>(new ResultObject<>(newFirm), HttpStatus.OK);
    }

    /**
     * 根据单位ID删除单位
     * @param id 单位ID
     */
//    @ApiOperation("根据单位ID删除单位")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    @OperationRecord(menu = "单位管理", actionType = SystemConsts.ACTION.DELETE)
//    public ResponseEntity<ResultObject> delete(@PathVariable("id") Long id) {
//        firmService.deleteFirm(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新单位（更新全部字段）
     * @param id 单位ID
     * @param firm 单位对象
     * @param parentId 父单位ID
     */
//    @ApiOperation("更新单位（更新全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "parentId", value = "父单位ID", dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    @OperationRecord(menu = "单位管理", actionType = SystemConsts.ACTION.EDIT)
//    public ResponseEntity<ResultObject> put(@PathVariable("id") Long id,
//                                            @RequestBody Firm firm,
//                                            @RequestParam("parentId") Optional<Long> parentId)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        firm.setId(id);
//        Firm newFirm = firmService.updateFirm(firm, parentId.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newFirm), HttpStatus.OK);
//    }

    /**
     * 更新单位（更新指定字段）
     * @param id
     * @return
     * @throws ArgumentErrorException
     * @throws ObjectNotFoundException
     * @throws UniqueConstraintsException
     */
    @ApiOperation("更新单位（更新指定字段）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType="long", paramType = "path")
    })
    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
    @OperationRecord(menu = "单位管理", actionType = SystemConsts.ACTION.EDIT)
    public ResponseEntity<ResultObject> patch(@PathVariable("id") Long id,
                                              @RequestBody Project project)
            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
        Firm newFirm = firmService.updateFirm(id,project);
        return new ResponseEntity<>(new ResultObject<>(newFirm), HttpStatus.OK);
    }

    /**
     * 根据单位ID获得单位
     * @param id 单位ID
     */
    @ApiOperation("根据单位ID获得单位")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path")
    })
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> get(@PathVariable("id") Long id) {
        Firm firm = firmService.findByFirmId(id);
        return new ResponseEntity<>(new ResultObject<>(firm), HttpStatus.OK);
    }

    /**
     * 根据系统标识获得单位
     * @param system 单位ID
     */
    @ApiOperation("根据系统标识获得单位")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "system", value = "系统标识", required = true, dataType = "String", paramType = "path")
    })
    @RequestMapping(value = "/getAllFirm/{system}", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> getAllFirm(@PathVariable("system") String system) {
        Iterable<Firm> firms = firmService.findBySystem(system);
        List<Map<String,Object>> maps = new ArrayList<>();
        if(firms != null){
            for (Firm firm : firms) {
                Map<String,Object> map = new HashMap<>();
                map.put("id",firm.getId());
                map.put("title",firm.getEnterpriseFullName());
                maps.add(map);
            }
        }
        return new ResponseEntity<>(new ResultObject<>(maps), HttpStatus.OK);
    }

    /**
     * 根据单位代码获得单位
     * @param code 单位代码
     */
//    @ApiOperation("根据单位代码获得单位")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "单位代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/byCode/{code}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByCode(@PathVariable("code") Long code) {
//        Firm firm = firmService.findByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(firm), HttpStatus.OK);
//    }

    /**
     * 根据条件获得单位列表
     */
//    @ApiOperation("根据条件获得单位列表")
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search() {
//        Iterable<Firm> results = firmService.findFirms();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

    /**
     * 根据条件获得单位列表（非树形）
     */
//    @ApiOperation("根据条件获得单位列表（非树形）")
//    @RequestMapping(value = "/all", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findAll() {
//        Iterable<Firm> results = firmService.findAll();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

    @ApiOperation("单表集合")
    @RequestMapping(value = "/allFirms", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> findAllFirms() {
        Iterable<Firm> results = firmService.findAllFirms();
        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
    }

    /**
     * 绑定单位拥有的资源
     * @param id 单位ID
     * @param type 资源类型
     * @param resourceId 资源ID
     */
//    @ApiOperation("绑定单位拥有的资源")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "type", value = "资源类型", required = true, dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "resourceId", value = "资源ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/resources", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindResource(@PathVariable("id") Long id,
//                                                     @RequestParam("type") String type,
//                                                     @RequestParam("resourceId") Long resourceId)
//            throws DatabaseProcessException {
//        firmService.bindResource(id, type, resourceId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 解绑单位拥有的资源
     * @param id 单位ID
     * @param resourceId 菜单ID
     */
//    @ApiOperation("解绑单位拥有的资源")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "resourceId", value = "资源ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/resources", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> unbindResource(@PathVariable("id") Long id,
//                                                       @RequestParam("resourceId") Long resourceId)
//            throws DatabaseProcessException {
//        firmService.unbindResource(id, resourceId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新单位绑定的资源
     * @param id 单位ID
     * @param domainList 资源列表
     */
//    @ApiOperation("更新单位绑定的资源")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/resources", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateResource(@PathVariable("id") Long id,
//                                                       @RequestBody DomainList<ResourceTree> domainList)
//            throws ArgumentErrorException, DatabaseProcessException {
//        firmService.updateResource(id, domainList);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 根据单位ID获得资源树
     * @param id 单位ID
     * @param type 类型列表
     */
//    @ApiOperation("根据单位ID获得资源树")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "type", value = "类型（以逗号间隔）", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/resources", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getResources(@PathVariable("id") Long id,
//                                                     @RequestParam("type") Optional<List<String>> type)
//            throws DatabaseProcessException {
//        Iterable<ResourceTree> result = firmService.findResourceTreeByFirmId(id, type.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }

    /**
     * 获得有单位关联的地区对象
     */
//    @ApiOperation("获得有单位关联的地区对象")
//    @RequestMapping(value = "/areas", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> searchFirmAreas() {
//        Iterable<Area> results = firmService.findFirmAreas();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

    /**
     * 根据单位代码获得单位关联的地区对象
     * @param code 单位代码
     */
//    @ApiOperation("根据单位代码获得单位关联的地区对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "单位代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/areaByCode/{code}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> searchFirmAreas(@PathVariable("code") Long code) {
//        Area result = firmService.findAreaByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }

    /**
     * 根据单位获得关联的地区
     * @param id 地区ID
     * @return
     */
//    @ApiOperation("根据单位获得关联的地区")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/areas", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getArea(@PathVariable("id") Long id) {
//        Iterable<Area> results = firmService.findAreaByFirmId(id);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

    /**
     * 更新单位关联的地区对象
     * @param areaId 地区ID
     * @param id 单位ID
     */
//    @ApiOperation("更新单位关联的地区对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true,dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "areaId", value = "地区ID", required = true, dataType = "Long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/areas", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateArea(@PathVariable("id") Long id,
//                                                   @RequestParam("areaId") Long areaId)
//            throws ArgumentErrorException, DatabaseProcessException, ObjectNotFoundException {
//        firmService.updateArea(id, areaId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新单位关联的单位类型
     * @param id 单位ID
     * @param firmTypeId 单位类型ID
     */
//    @ApiOperation("更新单位关联的单位类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true,dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "firmTypeId", value = "单位类型ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/firmTypes", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateFirmType(@PathVariable("id") Long id,
//                                                       @RequestParam("firmTypeId") Long firmTypeId)
//            throws ArgumentErrorException, DatabaseProcessException, ObjectNotFoundException {
//        firmService.updateFirmTypeById(id, firmTypeId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 绑定单位有权限的菜单
     * @param id 单位ID
     * @param menuId 菜单ID
     */
//    @ApiOperation("绑定单位有权限的菜单")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "menuId", value = "菜单ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/menus/{menuId}", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindMenu(@PathVariable("id") Long id,
//                                                 @PathVariable("menuId") Long menuId)
//            throws DatabaseProcessException {
//        firmService.bindMenu(id, menuId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 绑定单位有权限的菜单
     * @param id 单位ID
     * @param menuId 菜单ID
     */
//    @ApiOperation("绑定单位有权限的菜单")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "menuId", value = "菜单ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/appMenus/{menuId}", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindAppMenu(@PathVariable("id") Long id,
//                                                    @PathVariable("menuId") Long menuId)
//            throws DatabaseProcessException {
//        firmService.bindAppMenu(id, menuId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 解绑单位有权限的菜单
     * @param id 单位ID
     * @param menuId 菜单ID
     */
//    @ApiOperation("解绑单位有权限的菜单")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "menuId", value = "菜单ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/menus/{menuId}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> unbindMenu(@PathVariable("id") Long id,
//                                                   @PathVariable("menuId") Long menuId) {
//        firmService.unbindMenu(id, menuId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新单位有权限的菜单
     * @param id 单位ID
     * @param menus 菜单ID（以逗号间隔）
     */
//    @ApiOperation("更新单位有权限的菜单")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "Long", paramType = "path"),
//            @ApiImplicitParam(name = "menus", value = "菜单ID（以逗号间隔）", dataType = "String", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/menus", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateMenu(@PathVariable("id") Long id,
//                                                   @RequestParam("menus") List<Long> menus)
//            throws DatabaseProcessException {
//        firmService.updateMenu(id, menus);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新单位绑定的首页
     * @param id 单位ID
     * @param homePageId 首页对象ID
     */
//    @ApiOperation("更新单位绑定的首页")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "homePageId", value = "首页对象ID", dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/homePages", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateRoles(@PathVariable("id") Long id,
//                                                    @RequestParam("homePageId") Long homePageId)
//            throws ObjectNotFoundException {
//        firmService.updateHomePage(id, homePageId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 根据单位ID获得其所有有权限的菜单列表
     * @param id 单位ID
     */
//    @ApiOperation("根据单位ID获得其所属菜单列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "Long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/menus", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getMenus(@PathVariable("id") Long id) {
//        Iterable<Menu> menus = firmService.findMenusByFirmId(id);
//        return new ResponseEntity<>(new ResultObject<>(menus), HttpStatus.OK);
//    }

    /**
     * 根据单位获得单位类型
     * @param id ID
     */
//    @ApiOperation("根据单位获得单位类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/firmTypes", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getFirmType(@PathVariable("id") Long id) {
//        FirmType firmType = firmService.findFirmTypeByFirmId(id);
//        return new ResponseEntity<>(new ResultObject<>(firmType), HttpStatus.OK);
//    }

    /**
     * 根据单位类型获得单位
     * @param firmTypeId 单位类型ID
     */
//    @ApiOperation("根据单位类型获得单位")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "firmTypeId", value = "单位类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/byFirmType/{firmTypeId}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getFirmsByFirmType(@PathVariable("firmTypeId") Long firmTypeId) {
//        Iterable<Firm> results = firmService.findFirmsByFirmTypeId(firmTypeId);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

    /**
     * 根据单位ID获得绑定的首页对象
     * @param id 单位ID
     */
//    @ApiOperation("根据单位ID获得绑定的首页对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/homePages", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getHomePage(@PathVariable("id") Long id) {
//        HomePage homePage = firmService.findHomePageByFirmId(id);
//        return new ResponseEntity<>(new ResultObject<>(homePage), HttpStatus.OK);
//    }

    /**
     * 根据设备ID获取单位
     * @param devId 设备ID
     */
//    @ApiOperation("根据设备ID获取单位")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "devId", value = "设备ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/byDevId/{devId}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findFirmByDevId(@PathVariable("devId") Long devId) {
//        Iterable<Firm> results = firmService.findFirmByDevId(devId);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }

    /**
     * 根据电站ID获取单位
     * @param stationId 电站ID
     */
    @ApiOperation("根据电站ID获取单位")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationId", value = "电站ID", required = true, dataType = "long", paramType = "query")
    })
    @RequestMapping(value = "/byStation", method = RequestMethod.GET)
    public ResponseEntity<ResultObject> findFirmByStationId(@RequestParam("stationId") Long stationId) {
        Firm result = firmService.findByStationId(stationId);
        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
    }

    /**
     * 绑定单位拥有的电站
     * @param id 单位ID
     * @param stationId 电站ID
     */
//    @ApiOperation("绑定单位拥有的电站")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "stationId", value = "电站ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/stations", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> bindStation(@PathVariable("id") Long id,
//                                                    @RequestParam("stationId") Long stationId) {
//        firmService.bindStation(id, stationId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 解绑单位拥有的电站
     * @param id 单位ID
     * @param stationId 电站ID
     */
//    @ApiOperation("解绑单位拥有的电站")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "stationId", value = "电站ID", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}/stations", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> unbindStation(@PathVariable("id") Long id,
//                                                      @RequestParam("stationId") Long stationId) {
//        firmService.unbindStation(id, stationId);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

    /**
     * 更新单位绑定的电站
     * @param id 单位ID
     * @param domainList 电站列表
     */
//    @ApiOperation("更新单位绑定的电站")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "单位ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}/stations", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> updateStation(@PathVariable("id") Long id,
//                                                      @RequestBody DomainList<Station> domainList) {
//        firmService.updateStation(id, domainList);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }

//    @ApiOperation("根据设备代码查找电站")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "devCode", value = "设备代码", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/byDevCode", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findFirmByDevCode(@RequestParam("devCode") Long devCode) {
//        Firm result = firmService.findFirmByDevCode(devCode);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
}